import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select
import os

# 打开浏览器
driver = webdriver.Chrome()
driver.maximize_window()

# 获取本地地址
url = 'file:///' + os.path.abspath('html') + '/注册a.html'
driver.get(url)

# alert 定位按钮
driver.find_element(By.ID, 'alert').click()

# 切换弹窗
alert = driver.switch_to.alert

# 获取文本
print(alert.text)

# 确定
alert.accept()

# 退出
time.sleep(2)
driver.quit()